home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / LBalloonTracker / LBalloonTracker.h < prev    next >
Encoding:
Text File  |  1996-10-24  |  4.4 KB  |  181 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    LBalloonTracker.h                      ©1996 CS&T Inc. All rights reserved.
  3. // ===========================================================================
  4. //    
  5. //    LBalloonTracker implements Balloon Help for PowerPlant view hierarchies.
  6. //    
  7.  
  8. #ifndef _H_LBalloonTracker
  9. #define _H_LBalloonTracker
  10.  
  11. #ifdef __MWERKS__
  12. #    pragma once
  13. #    pragma cplusplus on
  14. #endif
  15.  
  16. // PowerPlant headers
  17. #include <PP_Types.h>
  18.  
  19.  
  20. // forward class & structure declarations
  21. class    LPane;
  22. class    LView;
  23. struct    HMMessageRecord;
  24.  
  25.  
  26. class LBalloonTracker
  27. {
  28. public:
  29.     
  30.     // constructors / destructors
  31.                     LBalloonTracker();
  32.                     LBalloonTracker(ResIDT inBalloonsID);
  33.     virtual            ~LBalloonTracker();
  34.     
  35.     // inquiries
  36.     static Boolean    IsBalloonHelpAvailable();
  37.     
  38.     // modifiers
  39.     static void        RemoveBalloons();
  40.     static void        SetDefaultBalloonFile(Int16 inBalloonResFile);
  41.     void            SetBalloonDataID(ResIDT inBalloonDataID);
  42.     
  43. protected:
  44.     
  45.     // balloon tracking
  46.     void            TrackBalloons(
  47.                         LView*                inHitView, 
  48.                         Point                inPortPt);
  49.     virtual void    GetBalloonID(
  50.                         LPane*                inHitPane, 
  51.                         Point                inPortPt, 
  52.                         PaneIDT&            outPaneID, 
  53.                         Int16&                outHelpIndex, 
  54.                         Rect&                outHotRect, 
  55.                         Point&                outTipPoint) const;
  56.     virtual Boolean    FindBalloon(
  57.                         PaneIDT                inPaneID, 
  58.                         Int16                inHelpIndex, 
  59.                         HMMessageRecord&    outHelpMsg, 
  60.                         Int16&                outHelpOptions, 
  61.                         Int16&                outHelpProcID, 
  62.                         Int16&                outHelpVariant) const;
  63.     
  64.     // modifiers
  65.     void            RemoveBalloonsIfInTracker();
  66.     
  67. private:
  68.     
  69.     // constants
  70.     enum            { index_Bad = -1 };
  71.     
  72.     // nested classes
  73.     union            BalloonDef;
  74.     class            Init;
  75.     class            Loader;
  76.     
  77.     // inquiries
  78.     Boolean            HasBalloonFile() const;
  79.     Boolean            HasBalloonDataID() const;
  80.     Boolean            HasBalloonData() const;
  81.     
  82.     // modifiers
  83.     static void        ClearCache();
  84.     
  85.     // member variables
  86.     Int16                    mBalloonFile;
  87.     ResIDT                    mBalloonDataID;
  88.     BalloonDef**            mBalloonData;
  89.     
  90.     // static member variables
  91.     static Boolean            sHasBalloonHelp;
  92.     static LPane*            sLastBalloonPane;
  93.     static LBalloonTracker*    sLastBalloonTracker;
  94.     static Rect                sLastHelpRect;
  95.     static Int16            sLastHelpIndex;
  96.     static Int16            sLastHelpOptions;
  97.     static Int16            sLastHelpProcID;
  98.     static Int16            sLastHelpVariant;
  99.     static Point            sLastHelpTip;
  100.     static Init                sInit;
  101.     static Int16            sDefaultResFile;
  102.     
  103.     // friends
  104.     friend class            Init;
  105.     friend class            Loader;
  106. };
  107.  
  108.  
  109. //    Inline member function definitions
  110.  
  111.  
  112. // ---------------------------------------------------------------------------
  113. //        • IsBalloonHelpAvailable    [static]
  114. // ---------------------------------------------------------------------------
  115. //    Returns true if Balloon Help is available.
  116.  
  117. inline Boolean
  118. LBalloonTracker::IsBalloonHelpAvailable()
  119. {
  120.     return (sHasBalloonHelp);
  121. }
  122.  
  123.  
  124. // ---------------------------------------------------------------------------
  125. //        • HasBalloonFile
  126. // ---------------------------------------------------------------------------
  127. //    Internal function that returns true if this tracker has a valid resource 
  128. //    file.
  129.  
  130. inline Boolean
  131. LBalloonTracker::HasBalloonFile() const
  132. {
  133.     return (mBalloonFile != kResFileNotOpened);
  134. }
  135.  
  136.  
  137. // ---------------------------------------------------------------------------
  138. //        • HasBalloonDataID
  139. // ---------------------------------------------------------------------------
  140. //    Internal function that returns true if this tracker has a valid balloon 
  141. //    help resource ID.
  142.  
  143. inline Boolean
  144. LBalloonTracker::HasBalloonDataID() const
  145. {
  146.     return (mBalloonDataID != 0);
  147. }
  148.  
  149.  
  150. // ---------------------------------------------------------------------------
  151. //        • HasBalloonData
  152. // ---------------------------------------------------------------------------
  153. //    Internal function that returns true if this tracker has a valid balloon 
  154. //    help resource, and if that resource is currently in memory.
  155.  
  156. inline Boolean
  157. LBalloonTracker::HasBalloonData() const
  158. {
  159.     return ((mBalloonData != NULL) && (*mBalloonData != NULL));
  160. }
  161.  
  162.  
  163. // ---------------------------------------------------------------------------
  164. //        • ClearCache    [static]
  165. // ---------------------------------------------------------------------------
  166. //    Internal function that clears LBalloonTracker's cached information 
  167. //    describing the last balloon that it displayed.
  168.  
  169. inline void
  170. LBalloonTracker::ClearCache()
  171. {
  172.     sLastBalloonPane    = NULL;
  173.     sLastBalloonTracker    = NULL;
  174.     sLastHelpTip.h        = -32000;
  175.     sLastHelpTip.v        = -32000;
  176.     sLastHelpIndex        = index_Bad;
  177. }
  178.  
  179.  
  180. #endif    // _H_LBalloonTracker
  181.